<?php

namespace User\Controller;
use Common\Controller\PrettyRestController;
use Think\Controller\RestController;

Class UserController extends PrettyRestController {
    
    protected $allowMethod = array('get', 'put', 'post', 'delete');
    protected $allowType = array('json');

    public function user() {
        switch ($this->_method) {
            case 'get':
                $data = array(
                    'title' => 'this is the title',
                    'post' => C('TEST_CONFIG'),
                );
                $this->prettyResponse(200, 'OK', $data);
                break;

            case 'post':
                $data = array(
                    'title' => 'this is the title',
                    'post' => 'this is the post content via post method'
                );
                $this->prettyResponse(200, 'OK', $data);
                break;

            case 'put':
                $data = array(
                    'title' => 'this is the title',
                    'post' => 'this is the post content via put method'
                );
                $this->prettyResponse(200, 'OK', $data);
                break;

            case 'delete':
                $data = array(
                    'title' => 'this is the title',
                    'post' => 'this is the post content via delete method'
                );
                $this->prettyResponse(200, 'OK', $data);
                break;
        }
    }

    /*
    private function prettyResponse($status=200, $message="ok", $data=null, $type="json") {
        $responseData['status'] = $status;
        $responseData['message'] = $message;
        $responseData['content'] = $data;

        $this->response($responseData, $type);
    }
    */
}
